package com.yotoodesign.dianba.ui;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.View;

import com.yotoodesign.dianba.custom.CustomDialog;

public class DialogUtil {
	
	public static void show(Context context,String msg,
			final IDialogCallback callback,final int funcId,final Object...params){
		AlertDialog.Builder builder = new Builder(context);
		builder.setTitle("提示").setMessage(msg)
			.setPositiveButton("确认", new OnClickListener(){
				@Override
				public void onClick(DialogInterface dialog, int which) {
					if(callback!=null){
						callback.dialogExecute(funcId,params);
					}
					dialog.dismiss();
				}
			})
			.setNegativeButton("取消", new OnClickListener(){
				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
				}
				
			})
			.create().show();
	}
	
	/*
	 * 显示自定义对话框
	 */
	public static CustomDialog showCustomDialog(Context context,String message,View parent,int gravity){
		CustomDialog dialog = new CustomDialog(context).show(parent, gravity);
		dialog.getTvMsg().setText(message!=null?message:"");
		return dialog;
		
	}
	
	/*
	 * 显示分享对话框
	 */
	public static Share2Friends showSharedDialog(Context context,String message,View parent,int gravity){
		Share2Friends dialog = new Share2Friends(context).show(parent, gravity);
		dialog.getEtMsg().setText(message!=null?message:"");
		return dialog;
		
	}
	
}
